package conch.yaoms;

import java.awt.Color;
import java.awt.Component;

import javax.swing.JLabel;
import javax.swing.JList;
import javax.swing.ListCellRenderer;

import conch.yaoms.jni.ProcessItem;

public class ProcessListRenderer extends JLabel implements ListCellRenderer {

	private static final long serialVersionUID = 1027418048234459296L;

	public ProcessListRenderer() {
		setOpaque(true);
	}

	@Override
	public Component getListCellRendererComponent(JList list, Object value,
			int index, boolean isSelected, boolean cellHasFocus) {
		ProcessItem processItem = (ProcessItem) value;
		setText(" - " + processItem.processImageName + " - "
				+ processItem.processId);
		if (isSelected) {
			setForeground(Color.green);
		} else {
			setForeground(Color.black);
		}
		if (list.isEnabled()) {
			setBackground(Color.white);
		} else {
			setBackground(Color.gray);
		}
		return this;
	}
}
